<?php
$db = new Swoole\MySQL();
$server = array(
    'host' => '127.0.0.1',
    'user' => 'root',
    'password' => 'root',
    'database' => 'test',
);
$db->connect($server, function ($db, $result) {
    $data = $db->escape("abc'efg\r\n");
});